package cn.fjsay.java.demo3;

public class Teacher {
    private String name;
    private int age;
    public Teacher(){

    }

    public Teacher(String name, int age) {
        this.name = name;
        if (age>0&&age<150){
            this.age = age;
        }
        else {
            System.out.println("年龄数据异常");
        }
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age>0&&age<150){
            this.age=age;
        }
        else {
            System.out.println("年龄数据异常");
        }
    }

    @Override
    public String toString() {
        return "这个老师叫做"+ name + "有" + age +'岁';
    }
}
